package com.iflytek.sbd.es.impl;


import com.iflytek.sbd.es.OriginalElasticsearchClient;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * @program: myes
 * @description:
 * @author: 陈英俊
 * @create: 2021-09-13 15:04
 */
@Service
public class OriginalElasticsearchClientImpl implements OriginalElasticsearchClient {

    @Resource
    private RestHighLevelClient restHighLevelClient;

    @Override
    public SearchResponse search(SearchRequest searchRequest) {
        try {
            SearchResponse search = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
            return search;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }


}
